package com.spark.lola.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spark.lola.feign.PurReportFeignService;
import com.spark.lola.statistics.entity.StatisticsPurchase;
import com.spark.lola.statistics.request.PurReportDateRequest;
import com.spark.lola.statistics.vo.PurchaseStatisticsVo;
import com.spark.lola.statistics.vo.PurchaseWorkVo;
import com.spark.lola.support.common.entity.ShiroUser;
import com.spark.lola.support.common.util.ResponseBean;
import com.spark.lola.support.mybatis.entity.QueryParam;
import com.spark.lola.support.mybatis.entity.ShiroQueryParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @Author: DengYeJun
 * @Date: 2020/5/20 15:53
 */
@RequestMapping("/api/report/pur/")
@RestController
@Api(value = "/api/report/pur/", tags = "采购统计接口")
public class PurReportController {
    @Autowired
    private PurReportFeignService purReportFeignService;

    /**
     * 获取指定期间员工统计
     */
    @ApiOperation(value = "查询指定期间员工统计")
    @RequestMapping(value = "/statistics/employee",method = RequestMethod.POST)
    ResponseBean employeeStatistics(@RequestBody PurReportDateRequest request, @SessionAttribute ShiroUser shiroUser){
        PurchaseStatisticsVo vo = purReportFeignService.employeeStatistics(shiroUser,request.getStart(),request.getEnd());
        return ResponseBean.success(vo);
    }

    /**
     * 员工待处理业务
     * @param shiroUser
     * @return
     */
    @ApiOperation(value = "查询员工待处理业务")
    @RequestMapping(value = "/work/employee",method = RequestMethod.POST)
    ResponseBean employeeWork(@SessionAttribute ShiroUser shiroUser){
        PurchaseWorkVo vo = purReportFeignService.employeeWork(shiroUser);
        return ResponseBean.success(vo);
    }

    /**
     * 获取采购日报表
     */
    @ApiOperation(value = "查询采购日报表")
    @RequestMapping(value = "/report/purchase/day",method = RequestMethod.POST)
    ResponseBean dayPurchaseReport(@RequestBody QueryParam<StatisticsPurchase> queryBean,
                                   @SessionAttribute ShiroUser shiroUser){
        ShiroQueryParam<StatisticsPurchase> shiroQueryParam =new ShiroQueryParam<>();
        shiroQueryParam.setQueryParam(queryBean);
        shiroQueryParam.setShiroUser(shiroUser);
        Page<StatisticsPurchase> page = purReportFeignService.dayPurchaseReport(shiroQueryParam);
        return ResponseBean.success(page);
    }

    /**
     * 获取采购月报表
     */
    @ApiOperation(value = "查询采购月报表")
    @RequestMapping(value = "/report/purchase/month",method = RequestMethod.POST)
    ResponseBean monthPurchaseReport(@RequestBody QueryParam<StatisticsPurchase> queryBean,
                                                  @SessionAttribute ShiroUser shiroUser){
        ShiroQueryParam<StatisticsPurchase> shiroQueryParam =new ShiroQueryParam<>();
        shiroQueryParam.setQueryParam(queryBean);
        shiroQueryParam.setShiroUser(shiroUser);
        Page<StatisticsPurchase> page = purReportFeignService.monthPurchaseReport(shiroQueryParam);
        return ResponseBean.success(page);
    }

    /**
     * 获取采购年报表
     */
    @ApiOperation(value = "查询采购年报表")
    @RequestMapping(value = "/report/purchase/year",method = RequestMethod.POST)
    ResponseBean yearPurchaseReport(@RequestBody QueryParam<StatisticsPurchase> queryBean,
                                    @SessionAttribute ShiroUser shiroUser)
    {
        ShiroQueryParam<StatisticsPurchase> shiroQueryParam =new ShiroQueryParam<>();
        shiroQueryParam.setQueryParam(queryBean);
        shiroQueryParam.setShiroUser(shiroUser);
        Page<StatisticsPurchase> page = purReportFeignService.yearPurchaseReport(shiroQueryParam);
        return ResponseBean.success(page);
    }
}
